package com.rwx.reflect;

import com.rwx.reflect.model.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Reflect03 {

    public static void main(String[] args) throws ClassNotFoundException,
            NoSuchMethodException,
            InvocationTargetException,
            InstantiationException, IllegalAccessException {
        Class clazz=Class.forName("com.rwx.reflect.model.Student");
        Constructor con1 = clazz.getConstructor();
        Student stu = (Student) con1.newInstance();
        System.out.println(stu);
        System.out.println("=============================");

        Constructor con2 = clazz.getDeclaredConstructor(String.class, String.class);
        con2.setAccessible(true);
        Student zs = (Student) con2.newInstance("zs", "12");
        System.out.println(zs);


    }
}
